# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Ionut Biru <ibiru@archlinux.org>

pkgbase=at-spi2-core
pkgname=(
  at-spi2-core
  at-spi2-core-docs
)
pkgver=2.48.2
pkgrel=1
pkgdesc="Protocol definitions and daemon for D-Bus at-spi"
url="https://gitlab.gnome.org/GNOME/at-spi2-core"
arch=(x86_64)
license=(GPL2)
depends=(
  dbus
  glib2
  gsettings-desktop-schemas
  libx11
  libxml2
  libxtst
  systemd
)
makedepends=(
  dbus-broker
  gi-docgen
  git
  gobject-introspection
  meson
  python-sphinx
)
checkdepends=(
  at-spi2-core
)
_commit=36b6bae1542a5201ff25ed16e4c026512f4fecdb  # tags/AT_SPI2_CORE_2_48_2^0
source=("git+https://gitlab.gnome.org/GNOME/at-spi2-core.git#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd at-spi2-core
  git describe --tags | sed 's/^AT_SPI2_CORE_//;s/_/./g;s/-/+/g'
}

prepare() {
  cd at-spi2-core
}

build() {
  local meson_options=(
    -D default_bus=dbus-broker
    -D docs=true
  )

  arch-meson at-spi2-core build "${meson_options[@]}"
  meson compile -C build
}

check() {
  dbus-run-session meson test -C build --print-errorlogs
}

package_at-spi2-core() {
  optdepends=('dbus-broker: Alternative bus implementation')
  provides=(
    "at-spi2-atk=$pkgver-$pkgrel"
    "atk=$pkgver-$pkgrel"
    libatk-1.0.so
    libatk-bridge-2.0.so
    libatspi.so
  )
  conflicts=(
    'at-spi2-atk<=2.38.0-2'
    'atk<=2.38.0-2'
  )
  replaces=(
    'at-spi2-atk<=2.38.0-2'
    'atk<=2.38.0-2'
  )

  meson install -C build --destdir "$pkgdir"

  mkdir -p doc/usr/share
  mv {"$pkgdir",doc}/usr/share/doc
}

package_at-spi2-core-docs() {
  pkgdesc+=" (documentation)"
  depends=()

  mv doc/* "$pkgdir"
}

# vim:set sw=2 sts=-1 et:
